package com.tanhua.app.controller;

import com.aliyun.oss.ClientException;
import com.tanhua.api.db.UserInfoApi;
import com.tanhua.app.service.BaiduService;
import com.tanhua.app.service.RecommendService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.sql.ResultSet;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanHuaController {
    @Autowired
    private RecommendService recommendService;



    @GetMapping(value = "todayBest", name = "今日佳人")
    public ResponseEntity todayBest() {
        return recommendService.querryTodayBest();
    }
    @GetMapping(value = "/recommendation",name = "多个佳人推荐")
    public ResponseEntity todayBestList(@RequestParam(defaultValue = "1") Integer page,
                                        @RequestParam(defaultValue = "10") Integer pagesize){
        return recommendService.todayBestList(page,pagesize);
    }
    @GetMapping(value = "/{id}/personalInfo", name = "今日佳人")
    public ResponseEntity personalInfo(@PathVariable("id") Long id) {
        return recommendService.querryPersonalInfo(id);
    }

    @GetMapping(value = "/strangerQuestions",name="查询佳人的问题")
    public ResponseEntity strangerQuestions(Long userId){

        return recommendService.strangerQuestions(userId);
    }
    @PostMapping(value = "/strangerQuestions",name = "回复陌生人问题")
    public ResponseEntity strangerQuestions(@RequestBody Map<String,String> param){
        Long jRId = Long.parseLong(param.get("userId"));
        String reply = param.get("reply");
        return recommendService.toStrangerQuestions(jRId,reply);
    }
    @Autowired
    private BaiduService baiduService;

    @GetMapping(value = "/search", name = "搜索附件的人")
    public ResponseEntity search(String gender,Integer distance) throws ClientException {

        return baiduService.search(gender,distance);
    }
}
